import { z } from "zod";

const PRODUCT_MOUNTS = [
  "PRODUCT_OVERVIEW_CREATE",
  "PRODUCT_OVERVIEW_MORE_ACTIONS",
  "PRODUCT_DETAILS_MORE_ACTIONS",
  "PRODUCT_DETAILS_WIDGETS",
] as const;

const NAVIGATION_MOUNTS = [
  "NAVIGATION_CATALOG",
  "NAVIGATION_ORDERS",
  "NAVIGATION_CUSTOMERS",
  "NAVIGATION_DISCOUNTS",
  "NAVIGATION_TRANSLATIONS",
  "NAVIGATION_PAGES",
] as const;

const ORDER_MOUNTS = [
  "ORDER_DETAILS_MORE_ACTIONS",
  "ORDER_OVERVIEW_CREATE",
  "ORDER_DETAILS_WIDGETS",
  "DRAFT_ORDER_DETAILS_WIDGETS",
  "DRAFT_ORDER_DETAILS_MORE_ACTIONS",
  "ORDER_OVERVIEW_MORE_ACTIONS",
  "DRAFT_ORDER_OVERVIEW_CREATE",
  "DRAFT_ORDER_OVERVIEW_MORE_ACTIONS",
] as const;

const CUSTOMER_MOUNTS = [
  "CUSTOMER_OVERVIEW_CREATE",
  "CUSTOMER_OVERVIEW_MORE_ACTIONS",
  "CUSTOMER_DETAILS_MORE_ACTIONS",
  "CUSTOMER_DETAILS_WIDGETS",
] as const;

const CATEGORY_MOUNTS = [
  "CATEGORY_DETAILS_MORE_ACTIONS",
  "CATEGORY_OVERVIEW_CREATE",
  "CATEGORY_OVERVIEW_MORE_ACTIONS",
] as const;

const COLLECTION_MOUNTS = [
  "COLLECTION_DETAILS_MORE_ACTIONS",
  "COLLECTION_DETAILS_WIDGETS",
  "COLLECTION_OVERVIEW_CREATE",
  "COLLECTION_OVERVIEW_MORE_ACTIONS",
] as const;

const GIFT_CARD_MOUNTS = [
  "GIFT_CARD_DETAILS_MORE_ACTIONS",
  "GIFT_CARD_DETAILS_WIDGETS",
  "GIFT_CARD_OVERVIEW_CREATE",
  "GIFT_CARD_OVERVIEW_MORE_ACTIONS",
] as const;

const VOUCHER_MOUNTS = [
  "VOUCHER_DETAILS_MORE_ACTIONS",
  "VOUCHER_DETAILS_WIDGETS",
  "VOUCHER_OVERVIEW_CREATE",
  "VOUCHER_OVERVIEW_MORE_ACTIONS",
] as const;

const DISCOUNT_MOUNTS = [
  "DISCOUNT_DETAILS_MORE_ACTIONS",
  "DISCOUNT_OVERVIEW_CREATE",
  "DISCOUNT_OVERVIEW_MORE_ACTIONS",
] as const;

const MENU_MOUNTS = [
  "MENU_DETAILS_MORE_ACTIONS",
  "MENU_OVERVIEW_CREATE",
  "MENU_OVERVIEW_MORE_ACTIONS",
] as const;

const PAGE_MOUNTS = [
  "PAGE_DETAILS_MORE_ACTIONS",
  "PAGE_OVERVIEW_CREATE",
  "PAGE_OVERVIEW_MORE_ACTIONS",
] as const;

const PAGE_TYPE_MOUNTS = [
  "PAGE_TYPE_DETAILS_MORE_ACTIONS",
  "PAGE_TYPE_OVERVIEW_CREATE",
  "PAGE_TYPE_OVERVIEW_MORE_ACTIONS",
] as const;

const TRANSLATIONS_MOUNTS = ["TRANSLATIONS_MORE_ACTIONS"] as const;

// Create a const array with all mounts to preserve literal types
const ALL_MOUNTS_ARRAY = [
  ...CATEGORY_MOUNTS,
  ...COLLECTION_MOUNTS,
  ...CUSTOMER_MOUNTS,
  ...DISCOUNT_MOUNTS,
  ...GIFT_CARD_MOUNTS,
  ...MENU_MOUNTS,
  ...NAVIGATION_MOUNTS,
  ...ORDER_MOUNTS,
  ...PAGE_MOUNTS,
  ...PAGE_TYPE_MOUNTS,
  ...PRODUCT_MOUNTS,
  ...VOUCHER_MOUNTS,
  ...TRANSLATIONS_MOUNTS,
] as const;

// Create the zod enum from the tuple, ensuring proper type inference
export const ALL_APP_EXTENSION_MOUNTS = z.enum(ALL_MOUNTS_ARRAY);

export type AllAppExtensionMounts = z.infer<typeof ALL_APP_EXTENSION_MOUNTS>;

// Subset of mounts available for WIDGET target
export const WIDGET_AVAILABLE_MOUNTS = [
  "ORDER_DETAILS_WIDGETS",
  "PRODUCT_DETAILS_WIDGETS",
  "VOUCHER_DETAILS_WIDGETS",
  "DRAFT_ORDER_DETAILS_WIDGETS",
  "GIFT_CARD_DETAILS_WIDGETS",
  "CUSTOMER_DETAILS_WIDGETS",
  "COLLECTION_DETAILS_WIDGETS",
] as const;
